import math

print(math.factorial(4))
times = 0
for i in range(1,5):
    bw = i * 100
    for j in range(1,5):
        if i != j:
            sw = j * 10
            for k in range(1,5):
                if k != i and k != j:
                    gw = k
                    times = times + 1
                    print(bw+sw+gw)
                        
print(times)
                    
    
